package com.maktoub.project.service.impl.provider;

import com.maktoub.common.model.entity.UserInterfaceInfo;
import com.maktoub.common.service.RemoteUserInterfaceInfoService;
import com.maktoub.project.mapper.UserInterfaceInfoMapper;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author Maktoub
* @description 针对表【user_interface_info(用户接口调用)】的数据库操作Service实现
* @createDate 2024-05-16 19:11:10
*/
@DubboService
@Service
public class RemoteUserInterfaceInfoServiceImpl
    implements RemoteUserInterfaceInfoService {

    @Autowired
    private UserInterfaceInfoMapper userInterfaceInfoMapper;

    @Override
    public boolean addInvokeCount(String accessKey, Long interfaceId) {
        try {
            int b = userInterfaceInfoMapper.updateCountByAkInterfaceId(accessKey, interfaceId);

            System.out.println("b = " + b);
            return true;
        }
        catch (Exception e){
            return false;
        }
    }

    @Override
    public UserInterfaceInfo checkLeftNum(String accessKey, Long interfaceId) {
        try {
            UserInterfaceInfo userInterfaceInfo = userInterfaceInfoMapper.queryNumByAkInterfaceId(accessKey, interfaceId);
            return userInterfaceInfo;
        }
        catch (Exception e){
            return null;
        }
    }
}




